<%-- 
    Document   : fileupload
    Created on : 05 25, 11, 12:14:39 PM
    Author     : Lee
--%>



<%--
    Document   : loanapplication
    Created on : Apr 6, 2011, 3:37:32 PM
    Author     : Dine
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
    <head>
        <sj:head jqueryui="true" jquerytheme="south-street" compressed="false"/>
        <jsp:include page="WEB-INF/fragments/globalHead.html"/>
        <script src="resources/jquery/jquery.metadata.js" type="text/javascript"></script>
        <script src="resources/jquery/jquery.validate.js" type="text/javascript"></script>
        <title>Cashmate <s:property value="#session.branch.branchname"/></title>
        <style type="text/css">
            .autocomplete{
                font-size: 10px;
            }
            div.container {
                background-color: #eee;
                border: 1px solid red;
                margin: 5px;
                padding: 5px;
            }
            div.container ol li {
                list-style-type: disc;
                margin-left: 20px;
            }
            div.container { display: none }
            .container label.error {
                display: inline;
            }
            .tabs{
                font-size: 11px;
            }
            #loan, #borrower, #spouse, #business, #coborrower, #requirements{
                overflow: auto;
                height: 320px;
            }

        </style> <!--main.jsp css-->
        <script type="text/javascript">
            $(document).ready(function(e){
                $("#autocomplete").keyup(function(event){
                    if(event.keyCode == 13){
                        $("#go").click();
                    }
                });
                $("#loanappform").validate({
                    errorLabelContainer: $("#loanappform div.error")
                });

                var container = $('div.container');
                // validate the form when it is submitted
                var validator = $("#loanappform").validate({
                    errorContainer: container,
                    errorLabelContainer: $("ol", container),
                    wrapper: 'li',
                    meta: "validate"
                });

                $(".cancel").click(function() {
                    validator.resetForm();
                });
                var incdep = 1;
                var incref = 1;
                var incveh = 1;
                var incoth = 1;
                var incloans = 1;
                var incbus = 1;
                var incper = 1;
                var incsav = 1; 
                var incinf = 1;
                var incdoc = 1;
                $("#btndependent").click(function() {
                    var tobecloned = document.getElementById("tobecloned");
                    var cloned = tobecloned.cloneNode(true);
                    var i = parseInt(cloned.childNodes[1].textContent);
                    var i2 = i+incdep;
                    cloned.childNodes[1].textContent = i2;
                    document.getElementById("tbldependent").appendChild(cloned);
                    incdep++;
                });

                $("#btnloans").click(function() {
                    var tobecloned = document.getElementById("tobeclonedloan");
                    var cloned = tobecloned.cloneNode(true);
                    var i = parseInt(cloned.childNodes[1].textContent);
                    var i2 = i+incloans;
                    cloned.childNodes[1].textContent = i2;
                    document.getElementById("tblloan").appendChild(cloned);
                    incloans++;
                });

                $("#btnreferences").click(function() {
                    var tobecloned = document.getElementById("tobeclonedreferences");
                    var cloned = tobecloned.cloneNode(true);
                    var i = parseInt(cloned.childNodes[1].textContent);
                    var i2 = i+incref;
                    cloned.childNodes[1].textContent = i2;
                    document.getElementById("tblreferences").appendChild(cloned);
                    incref++;
                });

                $("#btnbus").click(function() {
                    var tobecloned1 = document.getElementById("tobeclonedbus");
                    var tobecloned2 = document.getElementById("tobeclonedaddress");
                    var tobecloned3 = document.getElementById("tobeclonedstability");
                    var cloned1 = tobecloned1.cloneNode(true);
                    var cloned2 = tobecloned2.cloneNode(true);
                    var cloned3 = tobecloned3.cloneNode(true);
                    var i = parseInt(cloned1.childNodes[1].textContent);
                    var i2 = i+incbus;
                    cloned1.childNodes[1].textContent = i2;
                    var i = parseInt(cloned2.childNodes[1].textContent);
                    var i2 = i+incbus;
                    cloned2.childNodes[1].textContent = i2;
                    var i = parseInt(cloned3.childNodes[1].textContent);
                    var i2 = i+incbus;
                    cloned3.childNodes[1].textContent = i2;
                    document.getElementById("tblbus").appendChild(cloned1);
                    document.getElementById("tbladdress").appendChild(cloned2);
                    document.getElementById("tblstability").appendChild(cloned3);
                    incbus++;
                });

                /* CI PART */

                $("#btnvehicle").click(function() {
                    var tobecloned = document.getElementById("tobeclonedvehicle");
                    var cloned = tobecloned.cloneNode(true);
                    var i = parseInt(cloned.childNodes[1].textContent);
                    var i2 = i+incveh;
                    cloned.childNodes[1].textContent = i2;
                    document.getElementById("tblvehicle").appendChild(cloned);
                    incveh++;
                });

                $("#btnother").click(function() {
                    var tobecloned = document.getElementById("tobeclonedother");
                    var cloned = tobecloned.cloneNode(true);
                    var i = parseInt(cloned.childNodes[1].textContent);
                    var i2 = i+incoth;
                    cloned.childNodes[1].textContent = i2;
                    document.getElementById("tblother").appendChild(cloned);
                    incoth++;
                });

                $("#btnpersonal").click(function() {
                    var tobecloned = document.getElementById("tobeclonedpersonal");
                    var cloned = tobecloned.cloneNode(true);
                    var i = parseInt(cloned.childNodes[1].textContent);
                    var i2 = i+incper;
                    cloned.childNodes[1].textContent = i2;
                    document.getElementById("tblpersonal").appendChild(cloned);
                    incper++;
                });

                $("#btnsavings").click(function() {
                    var tobecloned = document.getElementById("tobeclonedsavings");
                    var cloned = tobecloned.cloneNode(true);
                    var i = parseInt(cloned.childNodes[1].textContent);
                    var i2 = i+incsav;
                    cloned.childNodes[1].textContent = i2;
                    document.getElementById("tblsavings").appendChild(cloned);
                    incsav++;
                });

                $("#btninformants").click(function() {
                    var tobecloned = document.getElementById("tobeclonedinformants");
                    var cloned = tobecloned.cloneNode(true);
                    var i = parseInt(cloned.childNodes[1].textContent);
                    var i2 = i+incinf;
                    cloned.childNodes[1].textContent = i2;
                    document.getElementById("tblinformants").appendChild(cloned);
                    incinf++;
                });

                $("#btndocs").click(function() {
                    var tobecloned = document.getElementById("tobecloneddocs");
                    var cloned = tobecloned.cloneNode(true);
                    var i = parseInt(cloned.childNodes[1].textContent);
                    var i2 = i+incdoc;
                    cloned.childNodes[1].textContent = i2;
                    document.getElementById("tbldocs").appendChild(cloned);
                    incdoc++;
                });
                
                //                var incapp = 1;
                $("#btnbusiness").click(function() {
                    var tobecloned1 = document.getElementById("tobeclonedid");
                    var tobecloned2 = document.getElementById("tobeclonedname");
                    var tobecloned3 = document.getElementById("tobeclonedtype");
                    var tobecloned4 = document.getElementById("tobeclonedfloorarea");
                    var tobecloned5 = document.getElementById("tobeclonedlandarea");
                    var tobecloned6 = document.getElementById("tobeclonedbusstability");
                    var tobecloned7 = document.getElementById("tobeclonedbusmodel");
                    var tobecloned8 = document.getElementById("tobeclonedbusmake");
                    var tobecloned9 = document.getElementById("tobeclonedbusland");
                    var tobecloned10 = document.getElementById("tobecloneddas");
                    var tobecloned11 = document.getElementById("tobeclonedphone");
                    var tobecloned12 = document.getElementById("tobeclonedladd");
                    var tobecloned13 = document.getElementById("tobeclonedrental");
                    var tobecloned14 = document.getElementById("tobeclonedlname");
                    var cloned1 = tobecloned1.cloneNode(true);
                    var cloned2 = tobecloned2.cloneNode(true);
                    var cloned3 = tobecloned3.cloneNode(true);
                    var cloned4 = tobecloned4.cloneNode(true);
                    var cloned5 = tobecloned5.cloneNode(true);
                    var cloned6 = tobecloned6.cloneNode(true);
                    var cloned7 = tobecloned7.cloneNode(true);
                    var cloned8 = tobecloned8.cloneNode(true);
                    var cloned9 = tobecloned9.cloneNode(true);
                    var cloned10 = tobecloned10.cloneNode(true);
                    var cloned11= tobecloned11.cloneNode(true);
                    var cloned12 = tobecloned12.cloneNode(true);
                    var cloned13 = tobecloned13.cloneNode(true);
                    var cloned14 = tobecloned14.cloneNode(true);
                    var i = cloned1.childNodes[0].value = "";
                    document.getElementById("trid").appendChild(cloned1);
                    document.getElementById("trname").appendChild(cloned2);
                    document.getElementById("trtype").appendChild(cloned3);
                    document.getElementById("trfloorarea").appendChild(cloned4);
                    document.getElementById("trlandarea").appendChild(cloned5);
                    document.getElementById("trbusstability").appendChild(cloned6);
                    document.getElementById("trbusmodel").appendChild(cloned7);
                    document.getElementById("trbusmake").appendChild(cloned8);
                    document.getElementById("trbusland").appendChild(cloned9);
                    document.getElementById("trdas").appendChild(cloned10);
                    document.getElementById("trphone").appendChild(cloned11);
                    document.getElementById("trladd").appendChild(cloned12);
                    document.getElementById("trrental").appendChild(cloned13);
                    document.getElementById("trlname").appendChild(cloned14);
                    
                    //                    var i = parseInt(cloned12.childNodes[0].textContent);
                    //                    var i2 = i+incapp;
                    //                    cloned12.childNodes[0].textContent = i2;
                    //                    document.getElementById("trlabelapp").appendChild(cloned12);
                    //                    incapp++;
                });

                /* CI PART */

                /* APPR PART*/
                var incapp = 1;
                $("#btnappraisal").click(function() {
                    var tobecloned1 = document.getElementById("tobeclonedmakeandtype");
                    var tobecloned2 = document.getElementById("tobeclonedbrand");
                    var tobecloned3 = document.getElementById("tobeclonedserial");
                    var tobecloned4 = document.getElementById("tobeclonedmodel");
                    var tobecloned5 = document.getElementById("tobeclonedreg");
                    var tobecloned6 = document.getElementById("tobeclonedmotor");
                    var tobecloned7 = document.getElementById("tobeclonedchasis");
                    var tobecloned8 = document.getElementById("tobeclonedplate");
                    var tobecloned9 = document.getElementById("tobeclonedfair");
                    var tobecloned10 = document.getElementById("tobeclonedlocation");
                    var tobecloned11 = document.getElementById("tobeclonedgen");
                    var tobecloned12 = document.getElementById("tobeclonedapp");
                    var cloned1 = tobecloned1.cloneNode(true);
                    var cloned2 = tobecloned2.cloneNode(true);
                    var cloned3 = tobecloned3.cloneNode(true);
                    var cloned4 = tobecloned4.cloneNode(true);
                    var cloned5 = tobecloned5.cloneNode(true);
                    var cloned6 = tobecloned6.cloneNode(true);
                    var cloned7 = tobecloned7.cloneNode(true);
                    var cloned8 = tobecloned8.cloneNode(true);
                    var cloned9 = tobecloned9.cloneNode(true);
                    var cloned10 = tobecloned10.cloneNode(true);
                    var cloned11= tobecloned11.cloneNode(true);
                    var cloned12 = tobecloned12.cloneNode(true);
                    document.getElementById("trmakeandtype").appendChild(cloned1);
                    document.getElementById("trbrand").appendChild(cloned2);
                    document.getElementById("trserial").appendChild(cloned3);
                    document.getElementById("trmodel").appendChild(cloned4);
                    document.getElementById("trreg").appendChild(cloned5);
                    document.getElementById("trmotor").appendChild(cloned6);
                    document.getElementById("trchasis").appendChild(cloned7);
                    document.getElementById("trplate").appendChild(cloned8);
                    document.getElementById("trfair").appendChild(cloned9);
                    document.getElementById("trlocation").appendChild(cloned10);
                    document.getElementById("trgen").appendChild(cloned11);
                    
                    var i = parseInt(cloned12.childNodes[0].textContent);
                    var i2 = i+incapp;
                    cloned12.childNodes[0].textContent = i2;
                    document.getElementById("trlabelapp").appendChild(cloned12);
                    incapp++;
                });
                /* APPR PART*/

                $('#balance1').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#balance2').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#bankname1').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#bankname2').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#principalamt1').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#principalamt2').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#amountrequested').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#outstandingloan').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#education').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#foodandclothing').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#rentexpense').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#othersources').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#spouseincome').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#employement').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#business').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#netincomebeforetax').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#grossincome').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#totalexpenses').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#fatherage').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#motherage').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#lengthofrelationshipinyears1').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#lengthofrelationshipinyears2').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#lengthofrelationshipinyears3').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#value1').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#value2').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#value3').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#value4').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#value5').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                $('#value6').focusout(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    var id = this.id;
                    var val = document.getElementById(id).value;
                    if(isNaN(val)==true){
                        this.style.color = "red";
                    }else{
                        this.style.color = "black";
                    }
                })
                
                $('.rating1').change(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    
                    updateTotal1();
                    updateSuperTotal();
                    
                })
                
                $('.rating2').change(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    
                    updateTotal2();
                    updateSuperTotal();
                    
                })
                
                $('.rating3').change(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    
                    updateTotal3();
                    updateSuperTotal();
                    
                })
                
                $('.rating4').change(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    
                    updateTotal4();
                    updateSuperTotal();
                    
                })
                
                $('.rating5').change(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    
                    updateTotal5();
                    updateSuperTotal();
                    
                })
                
                $('.rating6').change(function(e){
                    e = e||window.event;
                    e.stopPropagation();
                    e.preventDefault();
                    
                    updateTotal6();
                    updateSuperTotal();
                    
                })
                
                
                function updateTotal1(){
                    var rating = document.getElementsByName("rating");
                    var totalrating = document.getElementById("totalrating_1");
                    totalrating.value="0";
                    var temp = 0;
                    for(var i=0; i<rating.length; i++){
                        if(rating[i].className=="rating1"){
                            temp+=parseInt(rating.item(i).value);
                        }
                    }
                    totalrating.value=temp;
                    
                    var perf = parseInt(document.getElementById("perfectrating_1").value);
                    var total = parseInt(totalrating.value);
                    var percentage = document.getElementsByName("percentage");
                    var catpercent = parseInt(percentage[0].value);
                    var percent1 = (total/perf)*catpercent;
                    
                    document.getElementById("percent_1").value=percent1;
                    
                }
                
                function updateTotal2(){
                    var rating = document.getElementsByName("rating");
                    var totalrating = document.getElementById("totalrating_2");
                    totalrating.value="0";
                    var temp = 0;
                    for(var i=0; i<rating.length; i++){
                        if(rating[i].className=="rating2"){
                            temp+=parseInt(rating.item(i).value);
                        }
                       
                    }
                    totalrating.value=temp;
                    
                    var perf = parseInt(document.getElementById("perfectrating_2").value);
                    var total = parseInt(totalrating.value);
                    var percentage = document.getElementsByName("percentage");
                    var catpercent = parseInt(percentage[1].value);
                    var percent2 = (total/perf)*catpercent;
                    
                    document.getElementById("percent_2").value=percent2;
                    
                }
                
                function updateTotal3(){
                    var rating = document.getElementsByName("rating");
                    var totalrating = document.getElementById("totalrating_3");
                    totalrating.value="0";
                    var temp = 0;
                    for(var i=0; i<rating.length; i++){
                        if(rating[i].className=="rating3"){
                            temp+=parseInt(rating.item(i).value);
                        }
                        
                    }
                    totalrating.value=temp;
                    
                    var perf = parseInt(document.getElementById("perfectrating_3").value);
                    var total = parseInt(totalrating.value);
                    var percentage = document.getElementsByName("percentage");
                    var catpercent = parseInt(percentage[2].value);
                    var percent3 = (total/perf)*catpercent;
                    
                    document.getElementById("percent_3").value=percent3;
                    
                }

                function updateTotal4(){
                    var rating = document.getElementsByName("rating");
                    var totalrating = document.getElementById("totalrating_4");
                    totalrating.value="0";
                    var temp = 0;
                    for(var i=0; i<rating.length; i++){
                        if(rating[i].className=="rating4"){
                            temp+=parseInt(rating.item(i).value);
                        }
                        
                    }
                    totalrating.value=temp;
                    
                    var perf = parseInt(document.getElementById("perfectrating_4").value);
                    var total = parseInt(totalrating.value);
                    var percentage = document.getElementsByName("percentage");
                    var catpercent = parseInt(percentage[3].value);
                    var percent4 = (total/perf)*catpercent;
                    
                    document.getElementById("percent_4").value=percent4;
                    
                }
                function updateTotal5(){
                    var rating = document.getElementsByName("rating");
                    var totalrating = document.getElementById("totalrating_5");
                    totalrating.value="0";
                    var temp = 0;
                    for(var i=0; i<rating.length; i++){
                        if(rating[i].className=="rating5"){
                            temp+=parseInt(rating.item(i).value);
                        }
                        
                    }
                    totalrating.value=temp;
                    
                    var perf = parseInt(document.getElementById("perfectrating_5").value);
                    var total = parseInt(totalrating.value);
                    var percentage = document.getElementsByName("percentage");
                    var catpercent = parseInt(percentage[4].value);
                    var percent5 = (total/perf)*catpercent;
                    
                    document.getElementById("percent_5").value=percent5;
                    
                }
                function updateTotal6(){
                    var rating = document.getElementsByName("rating");
                    var totalrating = document.getElementById("totalrating_6");
                    totalrating.value="0";
                    var temp = 0;
                    for(var i=0; i<rating.length; i++){
                        if(rating[i].className=="rating6"){
                            temp+=parseInt(rating.item(i).value);
                        }
                    }
                    totalrating.value=temp;
                    
                    var perf = parseInt(document.getElementById("perfectrating_6").value);
                    var total = parseInt(totalrating.value);
                    var percentage = document.getElementsByName("percentage");
                    var catpercent = parseInt(percentage[5].value);
                    var percent6 = (total/perf)*catpercent;
                    
                    document.getElementById("percent_6").value=percent6;
                    
                }
                
                function updateSuperTotal(){
                    var g = document.getElementsByName("percent");
                    var tem = 0; 
                    for(var i=0;i<g.length;i++){
                        tem+=parseInt(g[i].value);
                    }
                    document.getElementById("total").value=tem;
                }


            })
            
            function load(){
                if(document.getElementById("perfectrating_1")!=null){
                    var x = document.getElementsByName("totalvalue");
                    var perf1 = document.getElementById("perfectrating_1");
                    var temp1 = 0;
                    var perf2 = document.getElementById("perfectrating_2");
                    var temp2 = 0;
                    var perf3 = document.getElementById("perfectrating_3");
                    var temp3 = 0;
                    var perf4 = document.getElementById("perfectrating_4");
                    var temp4 = 0;
                    var perf5 = document.getElementById("perfectrating_5");
                    var temp5 = 0;
                    var perf6 = document.getElementById("perfectrating_6");
                    var temp6 = 0;
                    for(var i = 0 ; i<x.length; i++){
                        if(x[i].getAttribute("class")=="totalvalue1"){
                            temp1+=parseInt(x[i].value);
                        }
                        if(x[i].getAttribute("class")=="totalvalue2"){
                            temp2+=parseInt(x[i].value);
                        }
                        if(x[i].getAttribute("class")=="totalvalue3"){
                            temp3+=parseInt(x[i].value);
                        }
                        if(x[i].getAttribute("class")=="totalvalue4"){
                            temp4+=parseInt(x[i].value);
                        }
                        if(x[i].getAttribute("class")=="totalvalue5"){
                            temp5+=parseInt(x[i].value);
                        }
                        if(x[i].getAttribute("class")=="totalvalue6"){
                            temp6+=parseInt(x[i].value);
                        }
                    }
                    perf1.value = temp1;
                    perf2.value = temp2;
                    perf3.value = temp3;
                    perf4.value = temp4;
                    perf5.value = temp5;
                    perf6.value = temp6;
                    document.getElementById("perfectrating_1").value;
                }
            }
        </script> <!--main.jsp script-->
    </head>
    <body onload="load()">

        <c:if test="${sessionScope.auth == null || sessionScope.auth == false}">
            <%--<jsp:forward page="index.jsp?auth=none"/>--%>
        </c:if>
        <s:div id="bodyContainer">
            <s:div id="logoContainer" cssClass="ui-widget-content ui-corner-all">
                <s:include value="WEB-INF/fragments/banner.jsp">
                    <s:param name="branch" value="#session.branch.branchname" />
                </s:include>
            </s:div>
            <jsp:include page="WEB-INF/fragments/top.jsp"/>
            <jsp:include page="WEB-INF/fragments/mainMenu.jsp?menu=Loan"/>
            <s:if test="#session.branch.branchname=='Head Office'">
                <jsp:include page="WEB-INF/fragments/left.jsp?type=loan&innerType=loanapplicationho&select1=subMenuLoanApplication&select2=loanApplicationHoSubMenu_${param.cat}"/>
            </s:if>
            <s:if test="#session.branch.branchname!='Head Office'">
                <jsp:include page="WEB-INF/fragments/left.jsp?type=loan&innerType=loanapplication&select1=subMenuLoanApplication&select2=loanApplicationSubMenu_${param.cat}"/> 
            </s:if>


            <s:div id="contentContainer" cssClass="ui-widget-content ui-corner-all">
                <h2>Struts2 File Upload & Save Example</h2>
                <s:actionerror />
                <s:form action="userImage" method="post" enctype="multipart/form-data">
                    <s:file name="userImage" label="User Image" />
                    <s:submit value="Upload" align="center" />
                </s:form>
            </s:div>
            <jsp:include page="WEB-INF/fragments/bottom.jsp"/>
        </s:div>
    </body>
</html>



